package com.lhys.mapper;

import com.lhys.dto.AssetUserDto;
import com.lhys.pojo.Asset;
import com.lhys.pojo.AssetUser;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: xiaoqi
 * Date: 2021/5/14
 * Time: 下午 18:33
 * Description: 资产用户持久层接口
 */
public interface AssetUserMapper {


    @Insert("INSERT INTO `asset_user`(`task_soft_type`, `login_name`, `user_type`, `username`, `password`, `nickname`, `gender`, `phone`, `depart`, `post`, `birthday`, `img`) " +
            "VALUES (#{taskSoftType}, #{loginName}, #{userType}, #{username}, #{password}, #{nickname}, #{gender}, #{phone}, #{depart} , #{post}, #{birthday}, #{img})")
    Integer addAssetUser(AssetUser assetUser);

    Integer updateAssetUser(AssetUser assetUser);

    @Delete("delete from asset_user where id = #{id}")
    Integer delAssetUserById(Integer id);

    @Select("select * from asset_user where binary login_name = #{loginName}")
    List<AssetUser> getAssetUserByLoginName(String loginName);

    @Select("select * from asset_user where binary login_name = #{loginName} and binary password = #{password}")
    AssetUser getAssetUserByLoginNameAndPassword(AssetUser assetUser);

    List<AssetUser> listAssetUserByPage(AssetUser assetUser);

    @Update("update asset_user set password = #{newPassword} where id = #{id}")
    Integer updatePasswordById(AssetUserDto assetUserDto);
}
